package com.ayoka.parenting.ui.group.report;

import android.graphics.Color;

import com.ayoka.parenting.R;
import com.ayoka.parenting.bean.CircleGroupBean;
import com.ayoka.parenting.bean.PagerBean;
import com.ayoka.parenting.bean.TodayReportBean;
import com.ayoka.parenting.interf.SimpleRequestCallback;
import com.ayoka.parenting.mvp.BasePresenterImpl;
import com.ayoka.parenting.widget.ReportCircleProgressView;
import com.jincp.common.utils.UIUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @ProjectName: MVPPlugin.
 * @ClassName: TodayReportTablePresenter.
 * @Description: .
 * @Author: jincp.
 * @CreateDate: 2019/10/10 18:17.
 */
public class TodayReportTablePresenter extends BasePresenterImpl<TodayReportTableContract.View> implements TodayReportTableContract.Presenter {

    private TodayReportTableModel model;

    public TodayReportTablePresenter() {
        model = new TodayReportTableModel();
    }

    @Override
    public void getTodayReportData(String topicId, String date) {
        mView.get().showWaitDialog(UIUtils.getString(R.string.loading));
        model.getTodayReportData(this, topicId, date, new SimpleRequestCallback<TodayReportBean>() {
            @Override
            public void onSuccess(TodayReportBean data) {
                if (!isAttached()) return;
                mView.get().hideWaitDialog();
                mView.get().configTodayReportData(data);
            }

            @Override
            public void onFailure(int errCode, String errMsg) {
                if (!isAttached()) return;
                mView.get().hideWaitDialog();
                mView.get().showToast(errMsg);
            }
        });
    }

    @Override
    public List<ReportCircleProgressView.CircleReportBean> getCircleReportBeanData(TodayReportBean todayReportBean) {
        List<ReportCircleProgressView.CircleReportBean> circleReportBeanList = new ArrayList<>();
        circleReportBeanList.add(new ReportCircleProgressView.CircleReportBean(Color.parseColor("#181837"), 15, 135, todayReportBean.CourseCompletedCounts * 360 / todayReportBean.MemberCounts));
        circleReportBeanList.add(new ReportCircleProgressView.CircleReportBean(Color.parseColor("#ffbb62"), 25, 90, todayReportBean.AssignmentCompletedCounts * 360 / todayReportBean.MemberCounts));
        circleReportBeanList.add(new ReportCircleProgressView.CircleReportBean(Color.parseColor("#3eb3fe"), 15, 50, todayReportBean.MeditationCompletedCounts * 360 / todayReportBean.MemberCounts));
        return circleReportBeanList;
    }
}
